#include "ConfigFile.h"

#ifdef _DEBUG
	#include <jmtools/LogManager.h>

	using namespace JMTools::Logs;
#endif

namespace JMTools
{
	namespace Config
	{
		ConfigFile::ConfigFile(std::string name)
		{
			this->name = name;
#ifdef _DEBUG
			if (LogManager::getInstance().getLog("JMTools_Config.log")==0);
				LogManager::getInstance().create("JMTools_Config.log",false);
#endif
		}

		ConfigFile::~ConfigFile()
		{
		}

		std::string ConfigFile::getName()
		{
			return this->name;
		}

		void ConfigFile::setName(std::string name)
		{
			this->name = name;
		}

		ConfigGroup * ConfigFile::getGroup(std::string name)
		{
			bool encontrado = false;
			ConfigGroup * group;
			std::list<ConfigGroup *>::iterator it;
			for (it = this->groups.begin();it != this->groups.end(); it++)
				if ((*it)->getName()==name)
				{
					encontrado = true;
					group = (*it);
				}
			return group;
		}

		void ConfigFile::addGroup(ConfigGroup * group)
		{
			this->groups.push_back(group);
		}
	}
}
